#include "headfiles.h"

using namespace std;

int main(int argc, char **argv) {
	if (argc != 3) {
		cout << "Usage: " << argv[0] << " node_file n" << endl;
		return 0;
	}

	char file_name[256];
	sprintf(file_name, "%s", argv[1]);
	int n = atoi(argv[2]);

	NODE *head;
	head = createLinkList(file_name);

	printLinkList(head);

	NODE *node = findNthLastNode(head, n);

	if (node) {
		cout << "The " << n << "th last node is: " << node->val << endl;
	}
	else {
		cout << "Number of nodes in link list is less than " << n <<"." << endl;
	}

	return 0;
}

